<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/taglibs.jsp"%>
<html>
	<head>
		<link href="${ctx}/css/main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
		<script language="javascript">
			var message = '${message}';
			if(message != ''){
				alert(message);
			}
			
			function doDelete(action,id){
				if(confirm('是否确认删除？')){
					location.href = "${ctx}/" + action + "?id=" + id ;
				}
			}
			
			function clickFile(action,id){
				location.href = "${ctx}/" + action + "?id=" + id;
			}
			
			function submitAction(action){
				document.manageForm.action = action ;
				document.manageForm.submit();
			}
			
			function saveAction(action) {
				if(document.getElementById("companyName").value == '') {
					alert('请输入公司名称');
					return ;
				}
				if(document.getElementById("category").value == '') {
					alert('请输入所属类别');
					return ;
				}
				if(document.getElementById("industry").value == '') {
					alert('请输入主营行业');
					return ;
				}
				if(document.getElementById("email").value == '') {
					alert('请输入电子邮件');
					return ;
				}
				if(document.getElementById("industryCategory").value == '') {
					alert('请输入公司类型');
					return ;
				}
				if(document.getElementById("managementMode").value == '') {
					alert('请输入经营模式');
					return ;
				}
				if(document.getElementById("establishDate").value == '') {
					alert('请输入公司成立时间');
					return ;
				}
				if(document.getElementById("userId").value == '') {
					alert('请输入公司所有者');
					return ;
				}
				submitAction(action);
			}
			
			function validateFileType() {
				fileName = manageForm.localFile.value;
				fileType = fileName.substr(fileName.lastIndexOf(".")).toLowerCase(); 
				if(fileType != '.jpg' && fileType != '.png' && fileType != '.jpeg' && fileType != '.gif' && fileType != '.bmp'){
					alert('图片文件类型错误，图片必须是以jpg,gif,jpeg,png,bmp为后缀文件');
					manageForm.localFile.outerHTML = manageForm.localFile.outerHTML;
					return false;
				}
			}
			
			var detail;
			function searchUserInfo() {
				if(!detail || detail.closed) {
					detail = window.open("about:blank", "company_owner_choose", "status,scrollbars,resizable=no,left=190,top=150,width=750,height=600");
				}
				ownerForm.target = "company_owner_choose";
				ownerForm.submit();
				detail.focus();
			}
		</script>
	</head>
	
	<body>
		<form name="ownerForm" id="ownerForm" method="post" action="searchProdOwner.ac"></form>
		<form method="post" action="" name="manageForm" ENCTYPE="multipart/form-data">
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td class="td11" align="left" colspan="4">
						<input type="button" name="search" value="保存" onClick="saveAction('companyInfoSave.ac')">
						<c:if test="${!empty companyInfo.id}">
							&nbsp;&nbsp;<input type="button" name="delete" value="删除" onClick="doDelete('companyInfoDelete.ac','${companyInfo.id}')">
						</c:if>
						&nbsp;&nbsp;<input type="button" name="back" value="返回" onClick="submitAction('backToCompanySearch.ac')">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						公司名称  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<input type="hidden" name="id" value="${companyInfo.id}">
						<input type="hidden" name="fileName" value="${companyInfo.fileName}">
						<c:if test="${empty companyInfo.id}">
							<input type="text" name="companyName" size="32" value="${companyInfo.companyName}">
						</c:if>
						<c:if test="${!empty companyInfo.id}">
							<input readonly="readonly" style="color:grey" type="text" name="companyName" size="32" value="${companyInfo.companyName}">
						</c:if>
					</td>
					<td width="20%" class="td2">
						所属类别  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="category" id="category" style="width:200px">
							<c:forEach var ="category" items="${sessionScope.T_companyCategoryList}">
								<c:if test="${companyInfo.category == category.typeCode}">
									<option value="${category.typeCode}" selected="selected">${category.typeName}</option>
								</c:if>
								<c:if test="${companyInfo.category != category.typeCode}">
									<option value="${category.typeCode}">${category.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						传真  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="foxNo" size="32" value="${companyInfo.foxNo}">
					</td>
					<td width="20%" class="td2">
						主营行业  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="industry" id="industry" style="width:200px">
							<c:forEach var ="industry" items="${sessionScope.T_companyIndustryList}">
								<c:if test="${companyInfo.industry == industry.typeCode}">
									<option value="${industry.typeCode}" selected="selected">${industry.typeName}</option>
								</c:if>
								<c:if test="${companyInfo.industry != industry.typeCode}">
									<option value="${industry.typeCode}">${industry.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						电子邮件 <span style="color:red;vertical-align:middle;">*</span>	  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="email" size="32" value="${companyInfo.email}">
					</td>
					<td width="20%" class="td2">
						公司类型  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="industryCategory" id="industryCategory" style="width:200px">
							<c:forEach var ="industryCategory" items="${sessionScope.T_companyIndustryCategoryList}">
								<c:if test="${companyInfo.industryCategory == industryCategory.typeCode}">
									<option value="${industryCategory.typeCode}" selected="selected">${industryCategory.typeName}</option>
								</c:if>
								<c:if test="${companyInfo.industryCategory != industryCategory.typeCode}">
									<option value="${industryCategory.typeCode}">${industryCategory.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>	
					<td width="20%" class="td2">
						法人代表	  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="manager" size="32" value="${companyInfo.manager}">
					</td>
					<td width="20%" class="td2">
						经营模式  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="managementMode" id="managementMode" style="width:200px">
							<c:forEach var ="managementMode" items="${sessionScope.T_companyManagementModeList}">
								<c:if test="${companyInfo.managementMode == managementMode.typeCode}">
									<option value="${managementMode.typeCode}" selected="selected">${managementMode.typeName}</option>
								</c:if>
								<c:if test="${companyInfo.managementMode != managementMode.typeCode}">
									<option value="${managementMode.typeCode}">${managementMode.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						注册资金
					</td>
					<td width="30%" class="td2" >
						<input type="text" name="regAmount" size="32" value="${companyInfo.regAmount}" align="right">
					</td>
					<td width="20%" class="td2">
						是否OEM代工
					</td>
					<td width="30%" class="td2">
						<select name="oemFlag" id="oemFlag" style="width:120px">
							<c:if test="${empty companyInfo.oemFlag}">
								<option value="1">是</option>
								<option value="0">否</option>
							</c:if>
							<c:if test="${companyInfo.oemFlag == 0}">
								<option value="1">是</option>
								<option value="0" selected="selected">否</option>
							</c:if>
							<c:if test="${companyInfo.oemFlag == 1}">
								<option value="1" selected="selected">是</option>
								<option value="0">否</option>
							</c:if>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						员工人数  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="staffCount" size="32" value="${companyInfo.staffCount}">
					</td>
					<td width="20%" class="td2">
						公司成立时间  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="20%" class="td2">
						<input size="28" readonly="readonly" id="establishDate" type="text" name="establishDate" value="${companyInfo.establishDate}"/>
						<img onclick="WdatePicker({el:'establishDate'})" src="${ctx}/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						研发人数  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="devCount" size="32" value="${companyInfo.devCount}">
					</td>
					<td width="20%" class="td2">
						公司标识图片
					</td>
					<td width="20%" class="td2" >
						<input type="file" name="localFile" size="24" value="" onchange="validateFileType();">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2"> 
						 公司所有者 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<input type="hidden" name="userId" value="${companyInfo.userId}"/>
						<input readonly="readonly" type="text" name="userName" size="28" value="${companyInfo.userName}">
						<img onclick="searchUserInfo()" src="${ctx}/images/index/search.gif" width="16" height="16" align="absmiddle">
					</td>
					<td width="10%" class="td2">  
						文件
					</td>
					<td width="30%" class="td2" colspan="3">
						<a href="javascript:clickFile('getCompanyLogo.ac','${companyInfo.id}');">${companyInfo.fileName}</a>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						年营业额（￥）
					</td>
					<td width="30%" class="td2">
						<input type="text" name="annualTumover" size="32" value="${companyInfo.annualTumover}" align="right">
					</td>
					<td width="20%" class="td2">
						年出口额  （￥）
					</td>
					<td width="30%" class="td2">
						<input type="text" name="exportAmount" size="32" value="${companyInfo.exportAmount}" align="right">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						开户银行
					</td>
					<td width="30%" class="td2">
						<input type="text" name="bank" size="32" value="${companyInfo.bank}">
					</td>
					<td width="20%" class="td2">
						银行帐号  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="bankAccount" size="32" value="${companyInfo.bankAccount}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						厂房面积（平方米）
					</td>
					<td width="30%" class="td2">
						<input type="text" name="area" size="32" value="${companyInfo.area}">
					</td>
					<td width="20%" class="td2">
						月产量（千克）  
					</td>
					<td width="30%" class="td2">
						<input type="text" name="monthlyProduction" size="32" value="${companyInfo.monthlyProduction}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
							质量控制  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="quality" size="95" value="${companyInfo.quality}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						主营产品或服务  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="proServer" size="95" value="${companyInfo.proServer}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						公司注册地  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="regAddress" size="95" value="${companyInfo.regAddress}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						主要经营地点  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="mainbusinessPlace" size="95" value="${companyInfo.mainbusinessPlace}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						主要市场  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="mainArea" size="95" value="${companyInfo.mainArea}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						主要客户  
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="mainCustomer" size="95" value="${companyInfo.mainCustomer}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						公司所在地
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="address" size="95" value="${companyInfo.address}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						公司主页
					</td>
					<td width="20%" class="td2" colspan="3">
						<input type="text" name="homepage" size="95" value="${companyInfo.homepage}">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2" colspan="4">
						公司简介 
					</td>
				</tr>
				<tr>
					<td width="100%" class="td2" colspan="4">
						<textarea id="summary" name="summary" rows="10" style="width:98%">
							${companyInfo.summary}
						</textarea>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>